-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Histogram breaks #767
Histogram breaks #767
Conversation
This is the implemented behavior of breaks. @edublancas Could you take a look at the demonstration and check whether it behaves as we want when you have time? Since I have two other issues, this does not need an immediate check. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks great! don't forget to add some reference images and test cases
src/sql/magic_plot.py
Outdated
bin_specified = False | ||
pattern = r"histogram.*( --bins | -b )" | ||
if re.search(pattern, line): | ||
bin_specified = True | ||
if re.search(r"( --breaks | -B )", line): | ||
raise exceptions.UsageError( | ||
"Both bins and breaks are specified. Must specify only one of them." | ||
) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can use cmd
to check if both arguments exist.
e.g.,
if cmd.args.bins and cmd.args.breaks:
raise UsageError(...)
let me know if that works, otherwise we should fix it since validating arguments with regular expressions is going to be a pain if we have more complex combinations
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because of the default value of bins (which is 50 for the magic command), cmd.args.bins
always return an integer value. Thus, I used the following code instead.
bin_specified = " --bins " in line or " -b " in line
breaks_specified = " --breaks " in line or " -B " in line
if bin_specified and breaks_specified:
raise exceptions.UsageError(...)
changelog test cases and fixes comments added
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LG, very comprehensive test case covered, GJ
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
Added some comments.
I think we should add some integration tests and make sure it works (or doesn't) on other databases (PostgreSQL, questdb, etc...)
if bins: | ||
raise ValueError( | ||
"Both bins and breaks are specified. Must specify only one of them." | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This error repeats itself. Can we delete the error handler from here?
Also, please change ValueError
to exceptions.ValueError
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deleted the error handler in magic_plot
and changed ValueError
to exceptions.ValueError
With this PR implementation, the following works.
|
Added test cases and images in |
@neelasha23 @yafimvo please review again |
Docs should be fine |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good, one thing is missing is adding one new test here:
"histogram-bins", |
you can just add an example that runs using --breaks
, let's see if it passes. if you find compatibilities, ping me and we can decide whether we support it or not. my guess is that it'll work with the databases that we're testing there
@edublancas I added |
awesome! |
Describe your changes
Implemented
--breaks/-B
to ggplot histogram.breaks demonstration.zip This notebook contains breaks demonstration and errors I implemented.
Issue number
Closes #719
Checklist before requesting a review
pkgmt format
📚 Documentation preview 📚: https://jupysql--767.org.readthedocs.build/en/767/